package com.onLineCar.manages.api.dto;

import cn.hutool.core.collection.CollectionUtil;
import com.onLineCar.manages.pojo.VehicleInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApiVehicleInfoDTO {
    private Long carId;
    private String plateNumber;
    private Long cityCode;
    private Long vehicleTypeId;

    public static List<ApiVehicleInfoDTO> convertToVehicleInfoDTOList(List<VehicleInfo> vehicleInfoList) {
        ArrayList<ApiVehicleInfoDTO> apiVehicleInfoDTOS = new ArrayList<>();
        if (CollectionUtil.isNotEmpty(vehicleInfoList)) {
            for (VehicleInfo vehicleInfo : vehicleInfoList) {
                ApiVehicleInfoDTO apiVehicleInfoDTO = new ApiVehicleInfoDTO();
                apiVehicleInfoDTO.setCarId(vehicleInfo.getVehicleId().longValue());
                apiVehicleInfoDTO.setPlateNumber(vehicleInfo.getLicensePlate());
                apiVehicleInfoDTO.setCityCode(vehicleInfo.getCityId().longValue());
                apiVehicleInfoDTO.setVehicleTypeId(vehicleInfo.getVehicleTypeId());
                apiVehicleInfoDTOS.add(apiVehicleInfoDTO);
            }
        }
        return apiVehicleInfoDTOS;
    }
}
